#ifndef RC5_H
#define RC5_H 

#include <avr/io.h>
#include <avr/interrupt.h>
//#include <avr/signal.h>
#include <avr/pgmspace.h>
#include <stdlib.h>

typedef unsigned char uchar;
typedef unsigned int uint;

#define xRC5_IN 	PIND
#define xRC5		PD7
#define RC5TIME 	1.778e-3		// 1.778msec
#define PULSE_MIN	(uchar)(XTAL / 512 * RC5TIME * 0.4 + 0.5)
#define PULSE_1_2	(uchar)(XTAL / 512 * RC5TIME * 0.8 + 0.5)
#define PULSE_MAX	(uchar)(XTAL / 512 * RC5TIME * 1.2 + 0.5)
#define XTAL		16e6
#define xSEND_LED	PD6
#define xSEND_OUT 	PORTD


extern uchar	rc5_bit;				// bit value
extern uchar	rc5_time;				// count bit time
extern uint	rc5_tmp;				// shift bits in
extern uint	rc5_data;				// store result

typedef struct rc5_t {
	uint flip;
	uint addr;
	uint value;
} rc5;

rc5 read_rc5();
void send_rc5(rc5 val);

#endif
